﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using ELearningSystem.Core.Interface;
using ELearningSystem.Core.Manager;
using ELearningSystem.DAO.DAO;

namespace ELearningSystem.Service
{
    /// <summary>
    /// Summary description for LearnerService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class LearnerService : System.Web.Services.WebService,IUserManager
    {
        IUserManager userManager = new UserManager();

        [WebMethod]
        public bool IsAuthenticatedUser(LearnerDAO aLearner, out LearnerDAO authenticatedLearner)
        {
            return userManager.IsAuthenticatedUser(aLearner, out authenticatedLearner);
        }

        [WebMethod]
        public bool IsAdmin(LearnerDAO aLearner)
        {
            return userManager.IsAdmin(aLearner);
        }

        [WebMethod]
        public LearnerDAO GetLearnerWithName(string name)
        {
            return userManager.GetLearnerWithName(name);
        }

        [WebMethod]
        public ScoreViewDAO GetUpdatedScore(LearnerDAO aLearner)
        {
            return userManager.GetUpdatedScore(aLearner);
        }

        [WebMethod]
        public ScoreViewDAO UpdateScoreAndReturnLatestScore(LearnerDAO learner, AttemptDAO attempt)
        {
            return userManager.UpdateScoreAndReturnLatestScore(learner, attempt);
        }

        [WebMethod]
        public bool SaveOrUpdateLearner(LearnerDAO learner, out string message)
        {
            return userManager.SaveOrUpdateLearner(learner, out message);
        }

        [WebMethod]
        public LearnerDAO GetLearnerWithEmail(string emailAddress)
        {
            return userManager.GetLearnerWithEmail(emailAddress);
        }
    }
}
